package com.heima.wemedia.controller.v1;

import com.heima.model.common.dtos.PageResponseResult;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.common.enums.AppHttpCodeEnum;
import com.heima.model.wemedia.dtos.WmSensitiveDto;
import com.heima.model.wemedia.dtos.WmSensitiveListDto;
import com.heima.wemedia.service.IWmSensitiveService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/sensitive")
@Slf4j
public class WmSensitiveController {
    @Autowired
    private IWmSensitiveService iWmSensitiveService;

    /**
     * 删除敏感词
     *
     * @param id
     * @return
     */
    @DeleteMapping("/del/{id}")
    public ResponseResult deleteSensitiveById(@PathVariable("id") Integer id) {
        return iWmSensitiveService.deleteByid(id);
    }

    /**
     * 敏感词分页查询
     *
     * @param dto
     * @return
     */
    @PostMapping("/list")
    PageResponseResult listSensitive(@RequestBody WmSensitiveListDto dto) {
        return iWmSensitiveService.listSensitive(dto);
    }

    /**
     * 添加敏感词
     *
     * @param dto
     * @return
     */
    @PostMapping("/save")
    public ResponseResult saveSensitive(@RequestBody WmSensitiveDto dto) {
        return iWmSensitiveService.saveSensitive(dto);
    }

    /**
     * 修改敏感词
     *
     * @param dto
     * @return
     */
    @PostMapping("/update")
    public ResponseResult updateSensitive(@RequestBody WmSensitiveDto dto) {
        return iWmSensitiveService.updateSensitive(dto);
    }
}
